import SelectionReplacePlugin from "./main";
import {App, Modal, Setting} from "obsidian";
import {CommonBatchJobUI, CommonSingleJobsUI} from "./common";

export class ExecuteUI extends Modal {
    plugin: SelectionReplacePlugin;
    commonSingleJobsUI: CommonSingleJobsUI;
    commonBatchJobUI: CommonBatchJobUI;
    constructor(app: App, plugin: SelectionReplacePlugin) {
        super(app);
        this.plugin = plugin;
        this.commonSingleJobsUI = new CommonSingleJobsUI(this.contentEl, this.plugin);
        this.commonBatchJobUI = new CommonBatchJobUI(this.contentEl, this.plugin);
    }

    onOpen() {
        this.contentEl.empty();
        this.commonSingleJobsUI.display();
        this.commonBatchJobUI.display();
        new Setting(this.contentEl).addButton((cb) => {
            cb.setButtonText("Run Batch Job")
                .setCta()
                .onClick(async () => {
                    await this.plugin.executeAllTagsJob(this.plugin.settings.scanRangePath, this.plugin.settings.outputPath);
                });
        })
    }
}